
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
//using System.Windows.Forms;

using System.Drawing.Imaging;
using System.Drawing.Drawing2D;

using System.Runtime.InteropServices;
using System.Text;

namespace EForms.Themes
{
	

	public class ButtonRenderer 
	{
		

		#region pens & brushes

		
		//private SolidBrush			textBrush;

		private static Schemes scheme = Schemes.Silver;

		private Rectangle[] rects0; 
		private Rectangle[] rects1; 

		private LinearGradientBrush 
			brushMarginEnabled, brushOlive1, 
			brushBlueSilver02, brushOlive02, 
			brushBlueSilver03, brushOlive03, brush05, brushSilver07, brushSilver10;
		private SolidBrush 
			brushBlue, brushOlive04, brushSilver04, brushSilver06, brushSilver08, brushMarginDisabled_2, brushMarginDisabled_1;
		private Pen 
			penBlueSilver01, penOlive01, penBlueSilver02, penOlive02,
			penBlueSilver03, penOlive03, penBlueSilver04, penOlive04,
			penBlueSilver05, penOlive05, penBlueSilver06, penOlive06,
			penBlueSilver07, penOlive07, penBlueSilver08, penOlive08, 
			penBlueSilver09, penOlive09, penBlueSilver10, penOlive10, 
			penBlueSilver11, penOlive11, penBlueSilver12, penOlive12, 
			penBlueSilver13, penOlive13, penBlueSilver14, penOlive14, 
			penBlueSilver15, penOlive15, penBlueSilver16, penOlive16, 
			pen17, pen18, pen19, pen20, pen21, pen22, pen23, pen24, pen01, pen02;

	
		private StringFormat		stringFormat;


		public ButtonRenderer()
		{
			ResetStringFormat();
			

		}
		public void ResetStringFormat()
		{
			if (this.stringFormat != null) 
				this.stringFormat.Dispose();
			this.stringFormat = new StringFormat();
			this.stringFormat.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
		}
		public StringFormat		StringFormat
		{
			get
			{
				return this.stringFormat;
			}
		}

		#endregion


		public void Paint(System.Windows.Forms.PaintEventArgs e, ButtonXP c)
		{
			if (c.Image != null)
			{
				if (c.Enabled) 
				{
					e.Graphics.DrawImage(c.Image, c.ImagePoint); 
				}
				else
				{
					System.Windows.Forms.ControlPaint.DrawImageDisabled(e.Graphics, c.Image, c.ImagePoint.X, c.ImagePoint.Y, c.BackColor);
				}
			}
			else
			{
				if (e.ClipRectangle.Width==0 || e.ClipRectangle.Height==0) 
					return;
				CreatePensBrushes(c);
				PaintBack(e, c);
			}
			
			//e.Graphics.DrawString(c.Text, c.Font, this.textBrush, c.TextPoint, this.stringFormat);
			e.Graphics.DrawString(c.Text, c.Font, c.TextBrush, c.TextPoint, this.StringFormat);
			

		
			//e.Graphics.DrawString(Text, Font, textBrush, textPoint, stringFormat);
			//e.Graphics.DrawString(c.Text, c.Font, this.textBrush, 2F, 2F);




			
		}
		
		private void PaintBack(System.Windows.Forms.PaintEventArgs e,  ButtonXP c)
		{
			int X = c.Width;
			int Y = c.Height;

			e.Graphics.CompositingQuality = CompositingQuality.GammaCorrected;
			if (!c.Enabled)
			{
				e.Graphics.FillRectangle(brushMarginDisabled_1, 2, 2, X-4, Y-4);
				e.Graphics.DrawLine(pen01, 3, 1, X-4, 1);
				e.Graphics.DrawLine(pen01, 3, Y-2, X-4, Y-2);
				e.Graphics.DrawLine(pen01, 1, 3, 1, Y-4);
				e.Graphics.DrawLine(pen01, X-2, 3, X-2, Y-4);

				e.Graphics.DrawLine(pen02, 1, 2, 2, 1);
				e.Graphics.DrawLine(pen02, 1, Y-3, 2, Y-2);
				e.Graphics.DrawLine(pen02, X-2, 2, X-3, 1);
				e.Graphics.DrawLine(pen02, X-2, Y-3, X-3, Y-2);
				e.Graphics.FillRectangles(brushMarginDisabled_2, rects1);
			} 
			else
			{

				e.Graphics.FillRectangle(brushMarginEnabled, new Rectangle(0, 0, X, Y));
				switch (c.State)
				{
					case States.Normal:
					switch (scheme)
					{
						case Schemes.Silver:
							e.Graphics.FillRectangle(brushSilver06, 2, 2, X-4, Y-4);
							e.Graphics.FillRectangle(brushSilver07, 3, 4, X-6, Y-8);
							e.Graphics.FillRectangle(brushSilver08, 2, Y-4, X-4, 2);

							if (c.IsDefault)
							{
								e.Graphics.FillRectangles(brushBlueSilver02, rects0);
								e.Graphics.DrawLine(pen23, 3, 4, 3, Y-4);
								e.Graphics.DrawLine(pen23, X-4, 4, X-4, Y-4);

								e.Graphics.DrawLine(penBlueSilver06, 2, 2, X-3, 2);
								e.Graphics.DrawLine(penBlueSilver07, 2, 3, X-3, 3);
								e.Graphics.DrawLine(penBlueSilver08, 2, Y-4, X-3, Y-4);
								e.Graphics.DrawLine(penBlueSilver09, 2, Y-3, X-3, Y-3);
							}
							break;

						case Schemes.OliveGreen:
							e.Graphics.FillRectangle(brushOlive1, 2, 2, X-4, Y-7);
							e.Graphics.DrawLine(penOlive01, 2, Y-5, X-2, Y-5);
							e.Graphics.DrawLine(penOlive02, 2, Y-4, X-2, Y-4);
							e.Graphics.DrawLine(penOlive03, 2, Y-3, X-2, Y-3);
							e.Graphics.DrawLine(penOlive04, X-4, 4, X-4, Y-5);
							e.Graphics.DrawLine(penOlive05, X-3, 4, X-3, Y-5);

							if (c.IsDefault)
							{
								e.Graphics.FillRectangles(brushOlive02, rects0);
								e.Graphics.DrawLine(penOlive06, 2, 2, X-3, 2);
								e.Graphics.DrawLine(penOlive07, 2, 3, X-3, 3);
								e.Graphics.DrawLine(penOlive08, 2, Y-4, X-3, Y-4);
								e.Graphics.DrawLine(penOlive09, 2, Y-3, X-3, Y-3);
							}
							break;

						default:
							e.Graphics.FillRectangle(brushOlive1, 2, 2, X-4, Y-7);
							e.Graphics.DrawLine(penBlueSilver01, 2, Y-5, X-2, Y-5);
							e.Graphics.DrawLine(penBlueSilver02, 2, Y-4, X-2, Y-4);
							e.Graphics.DrawLine(penBlueSilver03, 2, Y-3, X-2, Y-3);
							e.Graphics.DrawLine(penBlueSilver04, X-4, 4, X-4, Y-5);
							e.Graphics.DrawLine(penBlueSilver05, X-3, 4, X-3, Y-5);

							if (c.IsDefault)
							{
								e.Graphics.FillRectangles(brushBlueSilver02, rects0);
								e.Graphics.DrawLine(penBlueSilver06, 2, 2, X-3, 2);
								e.Graphics.DrawLine(penBlueSilver07, 2, 3, X-3, 3);
								e.Graphics.DrawLine(penBlueSilver08, 2, Y-4, X-3, Y-4);
								e.Graphics.DrawLine(penBlueSilver09, 2, Y-3, X-3, Y-3);
							}
							break;
					}
						break;

					case States.MouseOver:
					switch (scheme)
					{
						case Schemes.Silver:
							e.Graphics.FillRectangle(brushSilver06, 2, 2, X-4, Y-4);
							e.Graphics.FillRectangle(brushSilver07, 3, 4, X-6, Y-8);
							e.Graphics.FillRectangle(brushSilver08, 2, Y-4, X-4, 2);

							e.Graphics.FillRectangles(brushBlueSilver03, rects0);
							e.Graphics.DrawLine(penBlueSilver10, 2, 2, X-3, 2);
							e.Graphics.DrawLine(penBlueSilver11, 2, 3, X-3, 3);
							e.Graphics.DrawLine(penBlueSilver12, 2, Y-4, X-3, Y-4);
							e.Graphics.DrawLine(penBlueSilver13, 2, Y-3, X-3, Y-3);
							break;

						case Schemes.OliveGreen:
							e.Graphics.FillRectangle(brushOlive1, 2, 2, X-4, Y-7);
							e.Graphics.DrawLine(penOlive01, 2, Y-5, X-4, Y-5);
							e.Graphics.DrawLine(penOlive02, 2, Y-4, X-4, Y-4);
							e.Graphics.DrawLine(penOlive03, 2, Y-3, X-4, Y-3);
							e.Graphics.DrawLine(penOlive04, X-4, 4, X-4, Y-5);
							e.Graphics.DrawLine(penOlive05, X-3, 4, X-3, Y-5);

							e.Graphics.FillRectangles(brushOlive03, rects0);
							e.Graphics.DrawLine(penOlive10, 2, 2, X-3, 2);
							e.Graphics.DrawLine(penOlive11, 2, 3, X-3, 3);
							e.Graphics.DrawLine(penOlive12, 2, Y-4, X-3, Y-4);
							e.Graphics.DrawLine(penOlive13, 2, Y-3, X-3, Y-3);
							break;

						default:
							e.Graphics.FillRectangle(brushOlive1, 2, 2, X-4, Y-7);
							e.Graphics.DrawLine(penBlueSilver01, 2, Y-5, X-4, Y-5);
							e.Graphics.DrawLine(penBlueSilver02, 2, Y-4, X-4, Y-4);
							e.Graphics.DrawLine(penBlueSilver03, 2, Y-3, X-4, Y-3);
							e.Graphics.DrawLine(penBlueSilver04, X-4, 4, X-4, Y-5);
							e.Graphics.DrawLine(penBlueSilver05, X-3, 4, X-3, Y-5);

							e.Graphics.FillRectangles(brushBlueSilver03, rects0);
							e.Graphics.DrawLine(penBlueSilver10, 2, 2, X-3, 2);
							e.Graphics.DrawLine(penBlueSilver11, 2, 3, X-3, 3);
							e.Graphics.DrawLine(penBlueSilver12, 2, Y-4, X-3, Y-4);
							e.Graphics.DrawLine(penBlueSilver13, 2, Y-3, X-3, Y-3);
							break;
					}
						break;
		
					case States.Pushed:
					switch (scheme)
					{
						case Schemes.Silver:
							e.Graphics.FillRectangle(brushSilver06, 2, 2, X-4, Y-4);
							e.Graphics.FillRectangle(brushSilver10, 3, 4, X-6, Y-9);
							e.Graphics.DrawLine(pen24, 4, 3, X-4, 3);
							break;

						case Schemes.OliveGreen:
						default:
							e.Graphics.FillRectangle(brush05, 2, 4, X-4, Y-8);
							e.Graphics.DrawLine(pen17, 2, 3, 2, Y-4);
							e.Graphics.DrawLine(pen18, 3, 3, 3, Y-4);
							e.Graphics.DrawLine(pen19, 2, 2, X-3, 2);
							e.Graphics.DrawLine(pen20, 2, 3, X-3, 3);
							e.Graphics.DrawLine(pen21, 2, Y-4, X-3, Y-4);
							e.Graphics.DrawLine(pen22, 2, Y-3, X-3, Y-3);
							break;
					}
						break;
				}

				switch (scheme)
				{
					case Schemes.Silver:
						e.Graphics.DrawLine(penBlueSilver15, 1, 3, 3, 1);
						e.Graphics.DrawLine(penBlueSilver15, X-2, 3, X-4, 1);
						e.Graphics.DrawLine(penBlueSilver15, 1, Y-4, 3, Y-2);
						e.Graphics.DrawLine(penBlueSilver15, X-2, Y-4, X-4, Y-2);

						e.Graphics.DrawLine(penBlueSilver16, 1, 2, 2, 1);
						e.Graphics.DrawLine(penBlueSilver16, 1, Y-3, 2, Y-2);
						e.Graphics.DrawLine(penBlueSilver16, X-2, 2, X-3, 1);
						e.Graphics.DrawLine(penBlueSilver16, X-2, Y-3, X-3, Y-2);						

						e.Graphics.DrawLine(penBlueSilver14, 3, 1, X-4, 1);
						e.Graphics.DrawLine(penBlueSilver14, 3, Y-2, X-4, Y-2);
						e.Graphics.DrawLine(penBlueSilver14, 1, 3, 1, Y-4);
						e.Graphics.DrawLine(penBlueSilver14, X-2, 3, X-2, Y-4);

						e.Graphics.FillRectangles(brushSilver04, rects1);
						break;

					case Schemes.OliveGreen:
						e.Graphics.DrawLine(penOlive15, 1, 3, 3, 1);
						e.Graphics.DrawLine(penOlive15, X-2, 3, X-4, 1);
						e.Graphics.DrawLine(penOlive15, 1, Y-4, 3, Y-2);
						e.Graphics.DrawLine(penOlive15, X-2, Y-4, X-4, Y-2);

						e.Graphics.DrawLine(penOlive16, 1, 2, 2, 1);
						e.Graphics.DrawLine(penOlive16, 1, Y-3, 2, Y-2);
						e.Graphics.DrawLine(penOlive16, X-2, 2, X-3, 1);
						e.Graphics.DrawLine(penOlive16, X-2, Y-3, X-3, Y-2);						

						e.Graphics.DrawLine(penOlive14, 3, 1, X-4, 1);
						e.Graphics.DrawLine(penOlive14, 3, Y-2, X-4, Y-2);
						e.Graphics.DrawLine(penOlive14, 1, 3, 1, Y-4);
						e.Graphics.DrawLine(penOlive14, X-2, 3, X-2, Y-4);

						e.Graphics.FillRectangles(brushOlive04, rects1);
						break;

					default:
						e.Graphics.DrawLine(penBlueSilver15, 1, 3, 3, 1);
						e.Graphics.DrawLine(penBlueSilver15, X-2, 3, X-4, 1);
						e.Graphics.DrawLine(penBlueSilver15, 1, Y-4, 3, Y-2);
						e.Graphics.DrawLine(penBlueSilver15, X-2, Y-4, X-4, Y-2);

						e.Graphics.DrawLine(penBlueSilver16, 1, 2, 2, 1);
						e.Graphics.DrawLine(penBlueSilver16, 1, Y-3, 2, Y-2);
						e.Graphics.DrawLine(penBlueSilver16, X-2, 2, X-3, 1);
						e.Graphics.DrawLine(penBlueSilver16, X-2, Y-3, X-3, Y-2);						

						e.Graphics.DrawLine(penBlueSilver14, 3, 1, X-4, 1);
						e.Graphics.DrawLine(penBlueSilver14, 3, Y-2, X-4, Y-2);
						e.Graphics.DrawLine(penBlueSilver14, 1, 3, 1, Y-4);
						e.Graphics.DrawLine(penBlueSilver14, X-2, 3, X-2, Y-4);

						e.Graphics.FillRectangles(brushBlue, rects1);
						break;
				}

				if (c.Focused) 
					System.Windows.Forms.ControlPaint.DrawFocusRectangle(e.Graphics, 
									  new Rectangle(3, 3, X-6, Y-6), Color.Black, c.BackColor);        
			}
			DisposePensBrushes();
		}
	
	
		public void PaintBackground(System.Windows.Forms.PaintEventArgs pevent, System.Windows.Forms.Control c, EForms.Themes.States state)
		{
			
		}
		public void PaintBackground(System.Windows.Forms.PaintEventArgs pevent, System.Windows.Forms.Control c)
		{
			
		}

		private void DrawImage(System.Windows.Forms.PaintEventArgs pevent)
		{
			//gImage.Clear(Color.White/*EForms.Themes.Colors.DialogBackgroundLightLight*/);

			Graphics gImage = pevent.Graphics;

			int w = pevent.ClipRectangle.Width;
			int h = pevent.ClipRectangle.Height;

			Brush brushDark = new SolidBrush(System.Drawing.Color.FromArgb((System.Byte) 99, (System.Byte) 101, (System.Byte) 99)/*EForms.Themes.Colors.DialogBackgroundDark*/);
			Pen penDark = new Pen(brushDark,1);
			Pen penLight = new Pen(new SolidBrush(System.Drawing.Color.FromArgb((System.Byte) 239, (System.Byte) 239, (System.Byte) 239)/*EForms.Themes.Colors.DialogBackgroundLight*/),1);
			Pen penLightLight = new Pen(new SolidBrush(Color.White/*EForms.Themes.Colors.DialogBackgroundLightLight*/),1);

			// draw flat 3D border
			gImage.DrawLine(penLightLight, 0,0, w-1,0);
			gImage.DrawLine(penDark, 0,h-1, w,h-1);
			//gImage.DrawLine(penLight, 1 ,this.h-2, w-2,this.h-2);
			gImage.DrawLine(penLightLight, 0,1, 0, h-2);
			gImage.DrawLine(penDark, w-1,1,w-1, h-2);
			//gImage.DrawLine(penLight, w-2,1,w-2, h-2);

			//Dispose penline and graphics
			penDark.Dispose();
			penDark = null;
			penLight.Dispose();
			penLight = null;
			penLightLight.Dispose();
			penLightLight = null;
		}
		protected void CreatePensBrushes(System.Windows.Forms.Control c)
		{
			DisposePensBrushes();
			if (c.Region == null) 
				return;

			int X = c.Width;
			int Y = c.Height;

			brushMarginEnabled = ColorManager.Brush00(new Rectangle(0, 0, X, Y));
			brushBlueSilver02 = ColorManager.Brush02(Schemes.Blue, new Rectangle(2, 3, X-4, Y-7));
			brushOlive02 = ColorManager.Brush02(Schemes.OliveGreen, new Rectangle(2, 3, X-4, Y-7));
			brushBlueSilver03 = ColorManager.Brush03(Schemes.Blue, new Rectangle(2, 3, X-4, Y-7));
			brushOlive03 = ColorManager.Brush03(Schemes.OliveGreen, new Rectangle(2, 3, X-4, Y-7));
			
			brushBlue = ColorManager.Brush04(Schemes.Blue);
			brushOlive04 = ColorManager.Brush04(Schemes.OliveGreen);
			brushSilver04 = ColorManager.Brush04(Schemes.Silver);

			penBlueSilver06 = ColorManager.Pen06(Schemes.Blue);
			penOlive06 = ColorManager.Pen06(Schemes.OliveGreen);
			penBlueSilver07 = ColorManager.Pen07(Schemes.Blue);
			penOlive07 = ColorManager.Pen07(Schemes.OliveGreen);
			penBlueSilver08 = ColorManager.Pen08(Schemes.Blue);
			penOlive08 = ColorManager.Pen08(Schemes.OliveGreen);
			
			penBlueSilver09 = ColorManager.Pen09(Schemes.Blue);
			penOlive09 = ColorManager.Pen09(Schemes.OliveGreen);
			penBlueSilver10 = ColorManager.Pen10(Schemes.Blue);
			penOlive10 = ColorManager.Pen10(Schemes.OliveGreen);
			penBlueSilver11 = ColorManager.Pen11(Schemes.Blue);
			penOlive11 = ColorManager.Pen11(Schemes.OliveGreen);
			penBlueSilver12 = ColorManager.Pen12(Schemes.Blue);
			penOlive12 = ColorManager.Pen12(Schemes.OliveGreen);
			penBlueSilver13 = ColorManager.Pen13(Schemes.Blue);
			penOlive13 = ColorManager.Pen13(Schemes.OliveGreen);
			penBlueSilver14 = ColorManager.Pen14(Schemes.Blue);
			penOlive14 = ColorManager.Pen14(Schemes.OliveGreen);
			penBlueSilver15 = ColorManager.Pen15(Schemes.Blue);
			penOlive15 = ColorManager.Pen15(Schemes.OliveGreen);
			penBlueSilver16 = ColorManager.Pen16(Schemes.Blue);
			penOlive16 = ColorManager.Pen16(Schemes.OliveGreen);

			brushMarginDisabled_2 = ColorManager.Brush01(scheme);
			brushMarginDisabled_1 = ColorManager.Brush02(scheme);
			pen01 = ColorManager.Pen01_1(scheme);
			pen02 = ColorManager.Pen02_1(scheme);

			brushSilver06 = ColorManager.Brush06(); 
			brushSilver07 = ColorManager.Brush07(new Rectangle(3, 3, X-6, Y-7));
			brushSilver08 = ColorManager.Brush08(); 
			brushSilver10 = ColorManager.Brush09(new Rectangle(3, 3, X-5, Y-8));
			pen23 = ColorManager.Pen23();
			pen24 = ColorManager.Pen24();
		
			brushOlive1 = ColorManager.Brush01(scheme, new Rectangle(2, 2, X-5, Y-7));
			brush05 = ColorManager.Brush05(scheme, new Rectangle(2, 2, X-5, Y-7));

			penBlueSilver01 = ColorManager.Pen01(Schemes.Blue);
			penBlueSilver02 = ColorManager.Pen02(Schemes.Blue);
			penBlueSilver03 = ColorManager.Pen03(Schemes.Blue);
			penBlueSilver04 = ColorManager.Pen04(Schemes.Blue, new Rectangle(X-3, 4, 1, Y-5));
			penBlueSilver05 = ColorManager.Pen05(Schemes.Blue, new Rectangle(X-2, 4, 1, Y-5));

			penOlive01 = ColorManager.Pen01(Schemes.OliveGreen);
			penOlive02 = ColorManager.Pen02(Schemes.OliveGreen);
			penOlive03 = ColorManager.Pen03(Schemes.OliveGreen);
			penOlive04 = ColorManager.Pen04(Schemes.OliveGreen, new Rectangle(X-3, 4, 1, Y-5));
			penOlive05 = ColorManager.Pen05(Schemes.OliveGreen, new Rectangle(X-2, 4, 1, Y-5));

			pen17 = ColorManager.Pen17(scheme, new Rectangle(2, 3, X-4, Y-7));
			pen18 = ColorManager.Pen18(scheme, new Rectangle(3, 3, X-4, Y-7));
			pen19 = ColorManager.Pen19(scheme);
			pen20 = ColorManager.Pen20(scheme);
			pen21 = ColorManager.Pen21(scheme);
			pen22 = ColorManager.Pen22(scheme);

		
		}

		public void CreateRegion(System.Windows.Forms.Control c)
		{
			int X = c.Width;
			int Y = c.Height;

			rects0 = new Rectangle[2];
			rects0[0] = new Rectangle(2, 4, 2, Y-8);
			rects0[1] = new Rectangle(X-4, 4, 2, Y-8);

			rects1 = new Rectangle[8];
			rects1[0] = new Rectangle(2, 1, 2, 2); 
			rects1[1] =	new Rectangle(1, 2, 2, 2);
			rects1[2] =	new Rectangle(X-4, 1, 2, 2);
			rects1[3] =	new Rectangle(X-3, 2, 2, 2);
			rects1[4] =	new Rectangle(2, Y-3, 2, 2);
			rects1[5] =	new Rectangle(1, Y-4, 2, 2);
			rects1[6] =	new Rectangle(X-4, Y-3, 2, 2);
			rects1[7] =	new Rectangle(X-3, Y-4, 2, 2);
			
			Point[] points = {
								 new Point(1, 0),
								 new Point(X-1, 0),
								 new Point(X-1, 1),
								 new Point(X, 1),
								 new Point(X, Y-1),
								 new Point(X-1, Y-1),
								 new Point(X-1, Y),
								 new Point(1, Y),
								 new Point(1, Y-1),
								 new Point(0, Y-1),
								 new Point(0, 1),
								 new Point(1, 1)};

			GraphicsPath path = new GraphicsPath();
			path.AddLines(points);

			c.Region = new Region(path);
			//base.CreateRegion();
		}



		protected void DisposePensBrushes()
		{
			if (brushOlive1 != null) brushOlive1.Dispose();

			if (brushBlueSilver02 != null) brushBlueSilver02.Dispose();
			if (brushBlueSilver03 != null) brushBlueSilver03.Dispose();
			if (brushOlive02 != null) brushOlive02.Dispose();
			if (brushOlive03 != null) brushOlive03.Dispose();
			
			if (brushBlue != null) brushBlue.Dispose();
			if (brushOlive04 != null) brushOlive04.Dispose();
			if (brushSilver04 != null) brushSilver04.Dispose();

			if (brush05 != null) brush05.Dispose();
			if (brushSilver06 != null) brushSilver06.Dispose();
			if (brushSilver07 != null) brushSilver07.Dispose();
			if (brushSilver08 != null) brushSilver08.Dispose();
			if (brushSilver10 != null) brushSilver10.Dispose();

			if (penBlueSilver01 != null) penBlueSilver01.Dispose();
			if (penBlueSilver02 != null) penBlueSilver02.Dispose();
			if (penBlueSilver03 != null) penBlueSilver03.Dispose();
			if (penBlueSilver04 != null) penBlueSilver04.Dispose();
			if (penBlueSilver05 != null) penBlueSilver05.Dispose();
			if (penBlueSilver06 != null) penBlueSilver06.Dispose();
			if (penBlueSilver07 != null) penBlueSilver07.Dispose();
			if (penBlueSilver08 != null) penBlueSilver08.Dispose();			
			if (penBlueSilver09 != null) penBlueSilver09.Dispose();
			if (penBlueSilver10 != null) penBlueSilver10.Dispose();
			if (penBlueSilver11 != null) penBlueSilver11.Dispose();
			if (penBlueSilver12 != null) penBlueSilver12.Dispose();
			if (penBlueSilver13 != null) penBlueSilver13.Dispose();
			if (penBlueSilver14 != null) penBlueSilver14.Dispose();
			if (penBlueSilver15 != null) penBlueSilver15.Dispose();
			if (penBlueSilver16 != null) penBlueSilver16.Dispose();

			if (penOlive01 != null) penOlive01.Dispose();
			if (penOlive02 != null) penOlive02.Dispose();
			if (penOlive03 != null) penOlive03.Dispose();
			if (penOlive04 != null) penOlive04.Dispose();
			if (penOlive05 != null) penOlive05.Dispose();
			if (penOlive06 != null) penOlive06.Dispose();
			if (penOlive07 != null) penOlive07.Dispose();
			if (penOlive08 != null) penOlive08.Dispose();
			if (penOlive09 != null) penOlive09.Dispose();
			if (penOlive10 != null) penOlive10.Dispose();
			if (penOlive11 != null) penOlive11.Dispose();
			if (penOlive12 != null) penOlive12.Dispose();
			if (penOlive13 != null) penOlive13.Dispose();
			if (penOlive14 != null) penOlive14.Dispose();
			if (penOlive15 != null) penOlive15.Dispose();
			if (penOlive16 != null) penOlive16.Dispose();
			
			if (pen17 != null) pen17.Dispose();
			if (pen18 != null) pen18.Dispose();
			if (pen19 != null) pen19.Dispose();
			if (pen20 != null) pen20.Dispose();
			if (pen21 != null) pen21.Dispose();
			if (pen22 != null) pen22.Dispose();
			if (pen23 != null) pen23.Dispose();
			if (pen24 != null) pen24.Dispose();

			if (brushMarginDisabled_2 != null) brushMarginDisabled_2.Dispose();
			if (brushMarginDisabled_1 != null) brushMarginDisabled_1.Dispose();
			if (pen01 != null) pen01.Dispose();
			if (pen02 != null) pen02.Dispose();

		
		}



	}
	
}	// end of namespace